/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2009 University of Washington
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef IPV4_TEXCP_ROUTING_HELPER_H
#define IPV4_TEXCP_ROUTING_HELPER_H

#include "ns3/ipv4.h"
#include "ns3/ipv4-texcp-routing.h"
#include "ns3/texcp-queue.h"
#include "ns3/object-factory.h"
#include "ns3/ptr.h"
#include "ns3/ipv4-address.h"
#include "ns3/node.h"
#include "ns3/net-device.h"
#include "ipv4-routing-helper.h"
#include "node-container.h"
#include "trace-helper.h"
#include "net-device-container.h"

namespace ns3 {

namespace texcp_routing {
/**
 * \brief Helper class that adds ns3::Ipv4TexcpRouting objects
 *
 * This class is expected to be used in conjunction with 
 * ns3::InternetStackHelper::SetRoutingHelper
 */
class Ipv4TexcpRoutingHelper : public Ipv4RoutingHelper
{
public:
  /*
   * Construct an Ipv4TexcpRoutingHelper object, used to make configuration
   * of static routing easier.
   */
  Ipv4TexcpRoutingHelper ();

  /**
   * \brief Construct an Ipv4TexcpRoutingHelper from another previously 
   * initialized instance (Copy Constructor).
   */
  Ipv4TexcpRoutingHelper (const Ipv4TexcpRoutingHelper &);
  
  
  /**
   * \internal
   * \returns pointer to clone of this Ipv4TexcpRoutingHelper
   *
   * This method is mainly for internal use by the other helpers;
   * clients are expected to free the dynamic memory allocated by this method
   */
  Ipv4TexcpRoutingHelper* Copy (void) const;

  /**
   * \param node the node on which the routing protocol will run
   * \returns a newly-created routing protocol
   *
   * This method will be called by ns3::InternetStackHelper::Install
   */
  virtual Ptr<Ipv4RoutingProtocol> Create (Ptr<Node> node) const;

  /**
   * Try and find the static routing protocol as either the main routing
   * protocol or in the list of routing protocols associated with the 
   * Ipv4 provided.
   *
   * \param ipv4 the Ptr<Ipv4> to search for the static routing protocol
   */
  Ptr<Ipv4TexcpRouting> GetTexcpRouting (Ptr<Ipv4> ipv4) const;

  /**
   * Add the address of Egress peer
   *
   */
 void SetAttribute (std::string name, const AttributeValue &value); 

 void EnableAscii (std::string prefix, NodeContainer n);
 void TraceQueue (std::string prefix, NodeContainer n);

private:
  /**
   * \internal
   * \brief Assignment operator declared private and not implemented to disallow
   * assignment and prevent the compiler from happily inserting its own.
   */
  Ipv4TexcpRoutingHelper &operator = (const Ipv4TexcpRoutingHelper &o);
  ObjectFactory m_agentFactory; //Probabely should be deleted with ObjectFactory header file but no risk now 
  //void EnableAsciiImpl (Ptr<OutputStreamWrapper> stream, std::string prefix, NodeContainer n);
  //void EnableAsciiInternal (Ptr<OutputStreamWrapper> stream, std::string prefix, Ptr<Node> nd, bool explicitFilename);
  void EnableAsciiInternal (std::string prefix, Ptr<Node> nd );
  void TraceQueueInternal (std::string prefix, Ptr<Node> nd);
  static void DefaultUpdateFwnd (Ptr<OutputStreamWrapper> stream, Ptr<Ipv4TexcpTableEntry> p);
  static void QueueDrop (Ptr<OutputStreamWrapper> stream, Ptr<const Packet> p);
  static void QueueDroppingRate (Ptr<OutputStreamWrapper> stream, double oldValue, double newValue);
  static void LinkUtilization (Ptr<OutputStreamWrapper> stream, double oldValue, double newValue);
  static void TexcpForward (Ptr<OutputStreamWrapper> stream, const Ipv4Header &header, Ptr<const Packet> p, uint32_t interface);

};

}} // namespace ns3

#endif /* IPV4_TEXCP_ROUTING_HELPER_H */
